#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
using std::string;

#include <windows.h>
#include <process.h>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

#include "main_front.h"
#include "tracker.h"
#include "CarDB.h"

#include "OCREngine.h"

unsigned int __stdcall mainFrame(void *nothing);

int main (int argc, char **argv) {
	// the following two commands init the digit database, please do not remove.
	// later on we better get the directory from command line args/environment.
	string digitdir("data/digits/");
	OCREngine::instance()->init(digitdir);

	CvCapture* CaptureTop = cvCaptureFromAVI("\\\\ibm134\\Public\\temp\\Osl_clips\\demo_big.avi");


	CvCapture* CaptureFront = cvCaptureFromAVI("\\\\ibm134\\Public\\temp\\Osl_clips\\entrance_small.avi");

	
	//CvCapture* CaptureFront = cvCaptureFromAVI("\\\\ibm134\\Public\\temp\\Osl_clips\\entrance_better.avi");


	ParkinglotDB &bla=ParkinglotDB::instance();
	bla.InitLot();
	
	unsigned int tid=0;
	_beginthread(main_front, 0, (void *) CaptureFront);
	_beginthread(initParkinglot, 0, (void *) CaptureTop );
	//HANDLE hndl=(HANDLE)_beginthreadex(NULL,0,mainFrame,0,0,&tid);
	mainFrame(NULL);
	//string stam;
	//cin >> stam;
	//int x=8;
	//int y =480-132;
	//x=24; y=103;
	//carArrived(cvPoint(x,y), 4038);

	//cout << "main thread\n";	// if i use endl, there's a context switch before the new line :P
	//cin >> stam;
	//WaitForSingleObject(hndl,INFINITE);
	return 13;
}